# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


# useful for handling different item types with a single interface
from itemadapter import ItemAdapter


class MyspiderPipeline:

    def open_spider(self, spider):
        self.f = open("data.txt", mode="w", encoding="utf-8")

    # 处理数据，将数据保存起来
    def process_item(self, item, spider):
        title = item["title"]
        score = item["score"]
        dy = item["dy"]

        self.f.write("%s\t%s\t%s" % (title, score, dy))
        self.f.write("\n")

        return item
